/*
 * SPI.h
 *
 * Created: 04.01.2012 22:15:29
 *  Author: Luke
 */ 


#ifndef SPI_H_
#define SPI_H_

#define SPI_62k 3
#define SPI_125k 2
#define SPI_250k 6
#define SPI_500k 1
#define SPI_1M 5
#define SPI_2M 0
#define SPI_4M 4

// sets the SPI bus parameters (to 2MHZ)
void spiInit(void);

// sends data on the SPI bus. the ~Wait functions do busy wait for
// the "send complete" interrupt flag and return the contents of the 
// SPI data register after the transfer (clocked in from MISO)
// Chip select has to be done separately in software.

void spiSendByte(uint8_t);
uint8_t spiSendByteWait(uint8_t);
void spiSendWord(uint16_t);
uint16_t spiSendWordWait(uint16_t );
void spiSendDWordWait(uint32_t*);    
    
void spiSetSpeed(uint8_t);


#endif /* SPI_H_ */